home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / metafont.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  20.3 KB  |  564 lines

  1. /*
  2.  * $Id: metafont.trm,v 1.7 1995/12/20 21:47:59 drd Exp $
  3.  */
  4.  
  5. /*
  6.  *              GNUPLOT -- mf.trm
  7.  *
  8.  *            This terminal driver supports:
  9.  *               Metafont Plot Commands
  10.  *
  11.  * Written by : Pl Hedne
  12.  *        Trondheim, Norway
  13.  *        Pal.Hedne@termo.unit.no
  14.  */
  15.  
  16. /*
  17.  * Improvements and bug fixes by Carsten Steger:
  18.  * - Set default plot size to 5 by 3 inches as in the latex- and eepic-
  19.  *   drivers
  20.  * - Fixed some bugs concerning resolution dependent output
  21.  * - Added MF_scale function
  22.  * - Added MF_justify_text function and modified MF_put_text function and
  23.  *   put_text macro accordingly
  24.  * - Modified MF_move and MF_vector to make output shorter and modified
  25.  *   MF_text accordingly
  26.  * - Added various linetypes by plotting dashed lines; had to modify
  27.  *   MF_linetype and MF_vector for this
  28.  * - Added MF_arrow function
  29.  * - All global variables and #define'd names begin with MF_ now
  30.  * As a consequence almost nothing of the original code by Pl Hedne remains
  31.  * but credit goes to him for the ingenious trick of storing the character
  32.  * images into picture variables, without which this driver would have been
  33.  * impossible for me to write.
  34.  *
  35.  * 10/03/95: Converted to new terminal layout by Carsten Steger.
  36.  */
  37.  
  38. #ifndef GOT_DRIVER_H
  39. #include "driver.h"
  40. #endif
  41.  
  42. #ifdef TERM_REGISTER
  43. register_term(mf)
  44. #endif
  45.  
  46. #ifdef TERM_PROTO
  47.  
  48. #define MF_DPI (300)
  49. /* resolution of printer we expect to use; the value itself is not
  50.  * particularly important... it is here only for compatibility to the
  51.  * LaTeX-driver and to get the spacing right. */
  52.  
  53. /* 5 inches wide by 3 inches high (default) */
  54. #define MF_XSIZE 5.0
  55. #define MF_YSIZE 3.0
  56. #define MF_XMAX (MF_XSIZE*MF_DPI)
  57. #define MF_YMAX (MF_YSIZE*MF_DPI)
  58.  
  59. #define MF_HTIC (5*MF_DPI/72)
  60. #define MF_VTIC (5*MF_DPI/72)
  61. #define MF_HCHAR (MF_DPI*53/10/72)
  62. #define MF_VCHAR (MF_DPI*11/72)
  63.  
  64. TERM_PUBLIC void MF_init __P((void));
  65. TERM_PUBLIC void MF_graphics __P((void));
  66. TERM_PUBLIC void MF_text __P((void));
  67. TERM_PUBLIC int MF_justify_text __P((enum JUSTIFY mode));
  68. TERM_PUBLIC int MF_text_angle __P((int ang));
  69. TERM_PUBLIC void MF_linetype __P((int linetype));
  70. TERM_PUBLIC void MF_move __P((unsigned int x, unsigned int y));
  71. TERM_PUBLIC void MF_vector __P((unsigned int x, unsigned int y));
  72. TERM_PUBLIC void MF_arrow __P((unsigned int sx, unsigned int sy,
  73.                                unsigned int ex, unsigned int ey,
  74.                                TBOOLEAN head));
  75. TERM_PUBLIC void MF_put_text __P((unsigned int x, unsigned int y, char *str));
  76. TERM_PUBLIC void MF_reset __P((void));
  77.  
  78. #define GOT_MF_PROTO
  79.  
  80. #endif /* TERM_PROTO */
  81.  
  82.  
  83. #ifndef TERM_PROTO_ONLY
  84.  
  85. #ifdef TERM_BODY
  86.  
  87.  
  88. /* Plot size in inches */
  89. static double MF_xsize = MF_XSIZE;
  90. static double MF_ysize = MF_YSIZE;
  91. static int MF_char_code;
  92. static int MF_ang;
  93. static int MF_line_type;
  94. static enum JUSTIFY MF_justify;
  95. static double MF_dist_left;
  96. static int MF_is_solid;
  97. static int MF_picked_up_pen;
  98. /* 
  99.  * We keep track of where we are with respect to dashed lines by using
  100.  * the next five variables. MF_dash_index indicates which element of
  101.  * MF_lines[..].dashlen should be used. The MF_last.. variables keep
  102.  * track of the position of the pen.
  103.  */
  104. static int MF_dash_index;
  105. static unsigned int MF_last_x, MF_last_y;
  106.  
  107. static struct {
  108.   int solid;         /* Is the line solid? */
  109.   float thickness;   /* Thickness of pen we are going to use */
  110.   int dashlen[4];    /* Length of individual segments; even: line; odd: gap */
  111. } MF_lines[10] = {
  112.   {1,1.5,{0,0,0,0}},
  113.   {0,1.0,{MF_DPI/60,MF_DPI/50,MF_DPI/60,MF_DPI/50}},
  114.   {1,1.5,{0,0,0,0}},
  115.   {0,1.5,{MF_DPI/20,MF_DPI/30,MF_DPI/20,MF_DPI/30}},
  116.   {0,1.5,{MF_DPI/30,MF_DPI/20,MF_DPI/30,MF_DPI/20}},
  117.   {0,1.5,{MF_DPI/15,MF_DPI/30,MF_DPI/60,MF_DPI/30}},
  118.   {0,1.5,{MF_DPI/30,MF_DPI/50,MF_DPI/30,MF_DPI/50}},
  119.   {0,1.5,{MF_DPI/20,MF_DPI/50,MF_DPI/60,MF_DPI/30}},
  120.   {0,1.5,{MF_DPI/30,MF_DPI/50,MF_DPI/30,MF_DPI/30}},
  121.   {0,1.5,{MF_DPI/60,MF_DPI/50,MF_DPI/60,MF_DPI/30}}
  122.   /* dash: line,     gap,      line,     gap      */
  123. };
  124.  
  125.  
  126.  
  127. TERM_PUBLIC void MF_init ()
  128. {
  129.   MF_char_code = 0;
  130.   MF_ang = 0;
  131.  
  132.   fputs ("if unknown cmbase: input cmbase fi\n\n", outfile);
  133.   fputs ("tracingstats:=1;\n", outfile);
  134.   fputs ("picture r[];\n", outfile);
  135.   fputs ("\ndef openit = openwindow currentwindow\n", outfile);
  136.   fputs ("  from (0,0) to (400,800) at (-50,500) enddef;\n", outfile);
  137.  
  138.   fputs ("\nmode_setup;\n", outfile);
  139.  
  140.   fputs ("\n%Include next eight lines if you have problems with the mode on your system..\n", outfile);
  141.   fputs ("%proofing:=0;\n", outfile);
  142.   fputs ("%fontmaking:=1;\n", outfile);
  143.   fputs ("%tracingtitles:=0;\n", outfile);
  144.   fputs ("%pixels_per_inch:=300;\n", outfile);
  145.   fputs ("%blacker:=0;\n", outfile);
  146.   fputs ("%fillin:=.2;\n", outfile);
  147.   fputs ("%o_correction:=.6;\n", outfile);
  148.   fputs ("%fix_units;\n", outfile);
  149.  
  150.   /* Next lines must be included if text support is needed (CM base used) */
  151.   fputs ("\ndef put_text(expr ts,xstart,ystart,rot,justification) =\n", outfile);
  152.   fputs ("  begingroup\n", outfile);
  153.   fputs ("    text_width:=0;text_height:=0;\n", outfile);
  154.   fputs ("    for ind:=0 step 1 until length(ts)-1:\n", outfile);
  155.   fputs ("      dec_num:=ASCII substring (ind,ind+1) of ts;\n", outfile);
  156.   fputs ("      if unknown r[dec_num]: dec_num:=32; fi\n", outfile);
  157.   fputs ("      if dec_num=32: \n", outfile);
  158.   fputs ("        text_width:=text_width+wd[65];\n", outfile);
  159.   fputs ("        text_height:=max(text_height,ht[65]+dp[65]);\n", outfile);
  160.   fputs ("      elseif dec_num>=0: \n", outfile);
  161.   fputs ("        text_width:=text_width+wd[dec_num];\n", outfile);
  162.   fputs ("        text_height:=max(text_height,ht[dec_num]+dp[dec_num]);\n", outfile);
  163.   fputs ("      fi\n", outfile);
  164.   fputs ("    endfor\n", outfile);
  165.   fputs ("    if rot=90:\n", outfile);
  166.   fputs ("      if justification=1: ynext:=ystart;\n", outfile);
  167.   fputs ("      elseif justification=2: ynext:=round(ystart-text_width/2);\n", outfile);
  168.   fputs ("      else: ynext:=round(ystart-text_width);\n", outfile);
  169.   fputs ("      fi\n", outfile);
  170.   fputs ("      xnext:=xstart+text_height/2;\n", outfile);
  171.   fputs ("    else:\n", outfile);
  172.   fputs ("      if justification=1: xnext:=xstart;\n", outfile);
  173.   fputs ("      elseif justification=2: xnext:=round(xstart-text_width/2);\n", outfile);
  174.   fputs ("      else: xnext:=round(xstart-text_width);\n", outfile);
  175.   fputs ("      fi\n", outfile);
  176.   fputs ("      ynext:=ystart-text_height/2;\n", outfile);
  177.   fputs ("    fi\n", outfile);
  178.   fputs ("    for ind:=0 step 1 until length(ts)-1:\n", outfile);
  179.   fputs ("      dec_num:=ASCII substring (ind,ind+1) of ts;\n", outfile);
  180.   fputs ("      if unknown r[dec_num]: dec_num:=32; fi\n", outfile);
  181.   fputs ("      if dec_num=32: \n", outfile);
  182.   fputs ("        xnext:=xnext+wd[65]*cosd rot;\n", outfile);
  183.   fputs ("        ynext:=ynext+wd[65]*sind rot;\n", outfile);
  184.   fputs ("      elseif dec_num>=0: \n", outfile);
  185.   fputs ("        currentpicture:=currentpicture+r[dec_num] shifted(xnext,ynext)\n", outfile);
  186.   fputs ("          rotatedaround ((xnext,ynext),rot); \n", outfile);
  187.   fputs ("        xnext:=xnext+wd[dec_num]*cosd rot;\n", outfile);
  188.   fputs ("        ynext:=ynext+wd[dec_num]*sind rot;\n", outfile);
  189.   fputs ("      fi\n", outfile);
  190.   fputs ("    endfor\n", outfile);
  191.   fputs ("  endgroup \n", outfile);
  192.   fputs ("enddef;\n", outfile);
  193.  
  194.   fputs ("\ndef endchar =\n", outfile);
  195.   fputs ("  r[charcode]:=currentpicture;\n", outfile);
  196.   fputs ("  wd[charcode]:=w;ht[charcode]:=h;dp[charcode]:=d;\n", outfile);
  197.   fputs ("  message \"Picture of charcode no.\" & decimal charcode;\n", outfile);
  198.   fputs ("  endgroup;\n", outfile);
  199.   fputs ("enddef;\n", outfile);
  200.   fputs ("let endchar_ = endchar;\n", outfile);
  201.   fputs ("let generate = relax;\n", outfile);
  202.   fputs ("let roman = relax;\n", outfile);
  203.  
  204.   fputs ("input cmr10.mf\n", outfile);
  205.   fputs ("if ligs>1: font_coding_scheme:=\"TeX text\";\n", outfile);
  206.   fputs ("  spanish_shriek=oct\"074\"; spanish_query=oct\"076\";\n", outfile);
  207.   fputs ("else: font_coding_scheme:=\n", outfile);
  208.   fputs ("  if ligs=0: \"TeX typewriter text\"\n", outfile);
  209.   fputs ("  else: \"TeX text without f-ligatures\" fi;\n", outfile);
  210.   fputs ("  spanish_shriek=oct\"016\"; spanish_query=oct\"017\"; fi\n", outfile);
  211.   fputs ("font_setup;\n", outfile);
  212.   fputs ("input romanu.mf %Roman uppercase.\n", outfile);
  213.   fputs ("input romanl.mf %Roman lowerrcase.\n", outfile);
  214.   fputs ("input greeku.mf %Greek uppercase.\n", outfile);
  215.   fputs ("input romand.mf %Numerals.\n", outfile);
  216.   fputs ("input romanp.mf %Ampersand, question marks, currency sign.\n", outfile);
  217.   fputs ("input romspl.mf %Lowercase specials (dotless \\i, ligature \\ae, etc.)\n", outfile);
  218.   fputs ("input romspu.mf %Uppercase specials (\\AE, \\OE, \\O)\n", outfile);
  219.   fputs ("input punct.mf %Punctuation symbols.\n", outfile);
  220.   fputs ("\nminus=ASCII\"-\"; cmchar \"Minus sign\";\n", outfile);
  221.   fputs ("beginarithchar(minus); \n", outfile);
  222.   fputs ("  pickup rule.nib;\n", outfile);
  223.   fputs ("  lft x1=hround 1.5u-eps;\n", outfile);
  224.   fputs ("  x2=w-x1; y1=y2=math_axis;\n", outfile);
  225.   fputs ("  draw z1--z2;     % bar\n", outfile);
  226.   fputs ("  labels(1,2); \n", outfile);
  227.   fputs ("endchar;\n", outfile);
  228.  
  229.   fputs ("\ncmchar \"Period\";\n", outfile);
  230.   fputs ("  numeric dot_diam#; dot_diam#:=if monospace: 5/4 fi\\ dot_size#;\n", outfile);
  231.   fputs ("  define_whole_blacker_pixels(dot_diam);\n", outfile);
  232.   fputs ("  beginchar(\".\",5u#,dot_diam#,0);\n", outfile);
  233.   fputs ("  adjust_fit(0,0); pickup fine.nib;\n", outfile);
  234.   fputs ("  pos1(dot_diam,0); pos2(dot_diam,90);\n", outfile);
  235.   fputs ("  lft x1l=hround(.5w-.5dot_diam); bot y2l=0; z1=z2; dot(1,2);    % dot\n", outfile);
  236.   fputs ("  penlabels(1,2);\n", outfile);
  237.   fputs ("endchar;\n", outfile);
  238.  
  239.   fputs ("\ndef endchar =\n", outfile);
  240.   fputs ("  % Next line should probably be removed if CM base is used\n", outfile);
  241.   fputs ("  l:=0; r:=w;\n", outfile);
  242.   fputs ("  %Include the next two lines if you want to\n", outfile);
  243.   fputs ("  %rotate the picture 90 deg.(Portrait to Landscape)\n", outfile);
  244.   fputs ("  %currentpicture:=currentpicture rotated 90 shifted (h,0);\n", outfile);
  245.   fputs ("  %tmp:=charht; charht:=charwd; charwd:=tmp;\n", outfile);
  246.   fputs ("  scantokens extra_endchar;\n", outfile);
  247.   fputs ("  if proofing>0: makebox(proofrule); fi\n", outfile);
  248.   fputs ("  chardx:=w;\n", outfile);
  249.   fputs ("  shipit;\n", outfile);
  250.   fputs ("  if displaying>0: makebox(screenrule); showit; fi\n", outfile);
  251.   fputs ("  endgroup \n", outfile);
  252.   fputs ("enddef;\n", outfile);
  253.   fputs ("let endchar_ = endchar;\n", outfile);
  254.   fputs ("let generate = input;\n", outfile);
  255.   fputs ("let roman = roman;\n", outfile);
  256.  
  257.   fputs ("\n\nfont_identifier:=\"GNUPLOT\";\n", outfile);
  258.   /* font_size must be bigger than em#/16 by METAFONT rules.
  259.    * Therefore make it pretty big so big figures will be
  260.    * handled correctly. Setting font_size to 72pt# lets us
  261.    * handle characters up to 15.94 by 15.94 inches. */
  262.   fputs ("font_size 72pt#;\n", outfile);
  263.   fputs ("th#=0.4pt#; define_whole_pixels(th);\n", outfile);
  264.   fputs ("\npath arrowhead;\n", outfile);
  265.   fputs ("arrowhead = (-7pt,-2pt){dir30}..(-6pt,0pt)..", outfile);
  266.   fputs ("{dir150}(-7pt,2pt) &\n", outfile);
  267.   fputs ("  (-7pt,2pt)--(0pt,0pt)--(-7pt,-2pt) & cycle;\n", outfile);
  268. }
  269.  
  270.  
  271. TERM_PUBLIC void MF_graphics ()
  272. {
  273.   register struct termentry *t = term;
  274.  
  275.   fprintf (outfile, "\n\nbeginchar(%d,%gin#,%gin#,0);\n",
  276.            MF_char_code, MF_xsize, MF_ysize);
  277.   MF_char_code++;
  278.   fprintf (outfile, "a:=w/%d;b:=h/%d;\n", t->xmax, t->ymax);
  279.   MF_picked_up_pen = 0;
  280. }
  281.  
  282.  
  283. TERM_PUBLIC void MF_text ()
  284. {
  285.   fprintf (outfile, "endchar;\n");
  286. }
  287.  
  288.  
  289. TERM_PUBLIC int MF_justify_text (mode)
  290. enum JUSTIFY mode;
  291. {
  292.   MF_justify = mode;
  293.   return TRUE;
  294. }
  295.  
  296.  
  297. TERM_PUBLIC int MF_text_angle (ang)
  298. int ang;
  299. {
  300.   if (ang > 0) MF_ang = 90;
  301.   else MF_ang = 0;
  302.   return TRUE;
  303. }
  304.  
  305.  
  306. TERM_PUBLIC void MF_linetype (linetype)
  307. int linetype;
  308. {
  309.   if (linetype >=8) linetype %= 8;
  310.   linetype += 2;
  311.   /* Only output change in pens if it actually affects the pen used */
  312.   if ((MF_lines[linetype].thickness != MF_lines[MF_line_type].thickness) ||
  313.       (!MF_picked_up_pen)) {
  314.     fprintf (outfile, "pickup pencircle scaled %gth;\n",
  315.              MF_lines[linetype].thickness);
  316.     MF_picked_up_pen = 1;
  317.   }
  318.   MF_line_type = linetype;
  319.   MF_dash_index = 0;
  320.   MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index];
  321.   MF_is_solid = MF_lines[MF_line_type].solid;
  322. }
  323.  
  324.  
  325. TERM_PUBLIC void MF_move (x, y)
  326. unsigned int x, y;
  327. {
  328.   MF_last_x = x;
  329.   MF_last_y = y;
  330.   MF_dash_index = 0;
  331.   MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index];
  332. }
  333.  
  334.  
  335. TERM_PUBLIC void MF_vector (x, y)
  336. unsigned int x, y;
  337. {
  338.   if (MF_is_solid) {
  339.     if (x == MF_last_x && y == MF_last_y)
  340.       fprintf (outfile, "drawdot (%da,%db);\n", x, y);
  341.     else
  342.       fprintf (outfile, "draw (%da,%db)--(%da,%db);\n",
  343.                MF_last_x, MF_last_y, x, y);
  344.   } else {
  345.     double dist_to_go, delta_x, delta_y, inc_x, inc_y;
  346.     double last_x_d, last_y_d, next_x_d, next_y_d;
  347.     unsigned int next_x, next_y;
  348.  
  349.     if (x == MF_last_x && y == MF_last_y) {
  350.       if (! (MF_dash_index & 1))
  351.         fprintf (outfile, "drawdot (%da,%db);\n", x, y);
  352.     } else {
  353.       last_x_d = MF_last_x;
  354.       last_y_d = MF_last_y;
  355.       delta_x = x - last_x_d;
  356.       delta_y = y - last_y_d;
  357.       dist_to_go = sqrt (delta_x * delta_x + delta_y * delta_y);
  358.       inc_x = delta_x / dist_to_go;
  359.       inc_y = delta_y / dist_to_go;
  360.       while (MF_dist_left < dist_to_go) {
  361.         next_x_d = last_x_d + inc_x * MF_dist_left;
  362.         next_y_d = last_y_d + inc_y * MF_dist_left;
  363.         next_x = floor (next_x_d + 0.5);
  364.         next_y = floor (next_y_d + 0.5);
  365.         /* MF_dash_index & 1 == 0 means: draw a line; otherwise just move */
  366.         if (! (MF_dash_index & 1))
  367.           fprintf (outfile, "draw (%da,%db)--(%da,%db);\n",
  368.                    MF_last_x, MF_last_y, next_x, next_y);
  369.         MF_last_x = next_x;
  370.         MF_last_y = next_y;
  371.         last_x_d = next_x_d;
  372.         last_y_d = next_y_d;
  373.         dist_to_go -= MF_dist_left;
  374.         MF_dash_index = (MF_dash_index + 1) & 3;
  375.         MF_dist_left = MF_lines[MF_line_type].dashlen[MF_dash_index];
  376.       }
  377.       delta_x = x - last_x_d;
  378.       delta_y = y - last_y_d;
  379.       MF_dist_left -= sqrt (delta_x * delta_x + delta_y * delta_y);
  380.       if (! (MF_dash_index & 1)) {
  381.         if (x == MF_last_x && y == MF_last_y)
  382.           fprintf (outfile, "drawdot (%da,%db);\n", x, y);
  383.         else
  384.           fprintf (outfile, "draw (%da,%db)--(%da,%db);\n",
  385.                    MF_last_x, MF_last_y, x, y);
  386.       }
  387.     }
  388.   }
  389.   MF_last_x = x;
  390.   MF_last_y = y;
  391. }
  392.  
  393.  
  394. TERM_PUBLIC void MF_arrow (sx, sy, ex, ey, head)
  395. unsigned int sx, sy, ex, ey;
  396. TBOOLEAN head;
  397. {
  398.   int delta_x, delta_y;
  399.  
  400.   MF_move (sx, sy);
  401.   MF_vector (ex, ey);
  402.   if (head) {
  403.     delta_x = ex - sx;
  404.     delta_y = ey - sy;
  405.     fprintf (outfile, "fill arrowhead rotated angle(%d,%d) shifted (%da,%db);\n",
  406.              delta_x, delta_y, ex, ey);
  407.   } 
  408. }
  409.  
  410.  
  411. TERM_PUBLIC void MF_put_text (x, y, str)
  412. unsigned int x, y;
  413. char *str;
  414. {
  415.   int i, j=0;
  416.  
  417.   for (i = 0; i < strlen (str); i++)
  418.     if (str[i] == '"')
  419.       str[i] = '\'';        /* Replace " with ' */
  420.   switch (MF_justify) {
  421.     case LEFT:
  422.       j = 1;
  423.       break;
  424.     case CENTRE:
  425.       j = 2;
  426.       break;
  427.     case RIGHT:
  428.       j = 3;
  429.       break;
  430.   }
  431.   fprintf (outfile, "put_text(\"%s\",%da,%db,%d,%d);\n",
  432.            str, x, y, MF_ang, j);
  433. }
  434.  
  435.  
  436. TERM_PUBLIC void MF_reset ()
  437. {
  438.   fprintf (outfile, "end.\n");
  439. }
  440.  
  441.  
  442. #endif /* TERM_BODY */
  443.  
  444. #ifdef TERM_TABLE
  445.  
  446. TERM_TABLE_START(mf_driver)
  447.   "mf", "Metafont plotting standard",
  448.   MF_XMAX, MF_YMAX, MF_VCHAR, MF_HCHAR, 
  449.   MF_VTIC, MF_HTIC, options_null, MF_init, MF_reset, 
  450.   MF_text, null_scale, MF_graphics, MF_move, MF_vector, 
  451.   MF_linetype, MF_put_text, MF_text_angle, 
  452.   MF_justify_text, line_and_point, MF_arrow, set_font_null
  453. TERM_TABLE_END(mf_driver)
  454.  
  455. #undef LAST_TERM
  456. #define LAST_TERM mf_driver
  457.  
  458. #endif /* TERM_TABLE */
  459. #endif /* TERM_PROTO_ONLY */
  460.  
  461.  
  462. #ifdef TERM_HELP
  463. START_HELP(mf)
  464. "1 mf",
  465. "?set terminal mf",
  466. "?mf",
  467. "?metafont",
  468. " The mf terminal driver creates a input file to the METAFONT program.  Thus a",
  469. " figure may be used in the TeX document in the same way as a character is.",
  470. " To use the plot in a document the METAFONT program must be run with the",
  471. " output file from `gnuplot` as input.  Thus, the user needs a basic knowledge",
  472. " of the font creating process and the procedure for including a new font in a",
  473. " document.  However, if the METAFONT program is set up properly at the local",
  474. " site, an unexperienced user could perform the operation without much trouble.",
  475. " The text support is based on a METAFONT character set.  Currently the",
  476. " Computer Modern Roman font set is input, but the user is in principal free to",
  477. " chose whatever fonts he or she needs.  The METAFONT source files for the",
  478. " chosen font must be available.  Each character is stored in a separate",
  479. " picture variable in METAFONT.  These variables may be manipulated (rotated,",
  480. " scaled etc.) when characters are needed.  The drawback is the interpretation",
  481. " time in the METAFONT program.  On some machines (i.e. PC) the limited amount",
  482. " of memory available may also cause problems if too many pictures are stored.",
  483. "2 METAFONT Instructions",
  484. "?set terminal mf detailed",
  485. "?mf detailed",
  486. "?metafont detailed",
  487. " - Set your terminal to METAFONT:",
  488. "   set terminal mf",
  489. "",
  490. " - Select an output-file, e.g.:",
  491. "   set output \"myfigures.mf\"",
  492. "",
  493. " - Do your plots. Each plot will generate a separate character. Its default",
  494. "   size will be 5*3 inches. You can change the size by saying `set size 0.5,0.5`",
  495. "   or whatever fraction of the default size you want to have.",
  496. "",
  497. " - Quit `gnuplot`.",
  498. "",
  499. " - Generate a TFM and GF file by running METAFONT on the output of `gnuplot`.",
  500. "",
  501. " Since the plot is quite large (5*3 in), you will have to use a version of",
  502. " METAFONT that has a value of at least 150000 for memmax.  On Unix systems",
  503. " these are conventionally installed under the name bigmf.  For the following",
  504. " assume that the command virmf stands for a big version of METAFONT.  For",
  505. " example:",
  506. "",
  507. " - Invoke METAFONT:",
  508. "     virmf '&plain'",
  509. "",
  510. " - Select the output device: At the METAFONT prompt ('*') type:",
  511. "     \\mode:=CanonCX;     % or whatever printer you use",
  512. "",
  513. " - Optionally select a magnification:",
  514. "     mag:=1;             % or whatever you wish",
  515. "",
  516. " - Input the `gnuplot`-file:",
  517. "     input myfigures.mf",
  518. "",
  519. " On a typical Unix machine there will usually be a script called mf that",
  520. " executes virmf '&plain', so you probably can substitute mf for virmf &plain.",
  521. " This will generate two files: mfput.tfm and mfput.$$$gf (where $$$ indicates",
  522. " the resolution of your device).  The above can be conveniently achieved by",
  523. " typing everything on the command line, e.g.:",
  524. "",
  525. " virmf '&plain' '\\mode:=CanonCX; mag:=1; input myfigures.mf'",
  526. "",
  527. " In this case the output files will be named myfigures.tfm and",
  528. " myfigures.300gf.",
  529. "",
  530. " - Generate a PK file from the GF file using gftopk:",
  531. "   gftopk myfigures.300gf myfigures.300pk",
  532. "",
  533. " The name of the output file for gftopk depends on the DVI driver you use.",
  534. " Ask your local TeX administrator about the naming conventions.  Next, either",
  535. " install the TFM and PK files in the appropriate directories, or set your",
  536. " environment variables properly.  Usually this involves setting TEXFONTS to",
  537. " include the current directory and doing the same thing for the environment",
  538. " variable that your DVI driver uses (no standard name here...).  This step is",
  539. " necessary so that TeX will find the font metric file and your DVI driver will",
  540. " find the PK file.",
  541. "",
  542. " - To include your plots in your document you have to tell TeX the font:",
  543. "   \\font\\gnufigs=myfigures",
  544. "",
  545. " Each plot you made is stored in a single character.  The first plot is",
  546. " character 0, the second is character 1, and so on...  After doing the above",
  547. " step, you can use the plots just like any other characters.  Therefore, to",
  548. " place plots 1 and 2 centered in your document, all you have to do is:",
  549. "",
  550. "   \\centerline{\\gnufigs\\char0}",
  551. "   \\centerline{\\gnufigs\\char1}",
  552. "",
  553. " in plain TeX.  For LaTeX you can, of course, use the picture environment and",
  554. " place the plot according to your wishes using the \\makebox and \\put macros.",
  555. " This conversion saves you a lot of time once you have generated the font,",
  556. " since TeX handles the plots as characters and uses minimal time to place",
  557. " them.  Also the documents you make change more often than the plots do.  Also",
  558. " it saves a lot of TeX memory.  One last advantage of using the METAFONT",
  559. " driver is that the DVI file really remains device independent, because no",
  560. " \\special commands are used as in the eepic and tpic drivers."
  561. END_HELP(mf)
  562. #endif
  563.  
  564.